var wordBreak = function (s, wordDict) {
  // dp[i]记录了s（0，i-1）可以被wordDict的元素组合
  // dp[j] s(0,j-1)已经证明存在wordDict中 现在证明s(j,i-1)即可
  let dp = new Array(s.length+1).fill(false)
  // console.log(dp);
  dp[0] = true; //默认空字符串返回true
  for (let i=1;i<=s.length;i++) {
    for(var j = 0;j<i;j++) {
      if(dp[j]&&wordDict.includes(s.substring(j,i))){
        dp[i] = true
        break
      }
    }
  }
  console.log(dp);
  return dp[s.length]
};
let s = "catsandog", wordDict = ["cats","dog","sand","and","cat"]
// console.log(wordBreak(s, wordDict));
let a = new Array(5).fill([])
console.log(a);